package nsu.edu.zsq.service.impl.student;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import nsu.edu.zsq.bean.StuScore;
import nsu.edu.zsq.bean.Student;
import nsu.edu.zsq.common.RequestHolder;
import nsu.edu.zsq.dao.StuScoreMapper;
import nsu.edu.zsq.exception.ParamException;
import nsu.edu.zsq.param.StuScoreParam;
import nsu.edu.zsq.service.student.ScoreInfoService;

/** 
* Description: 学生成绩信息的service实现类<br>
*/

@Service
public class ScoreInfoServiceImpl implements ScoreInfoService{
    
    @Autowired
    private StuScoreMapper stuScoreMapper;

    @Override
    public List<StuScoreParam> listStuScoreParam() {
        Student student = RequestHolder.getCurrentStudent();
        List<StuScoreParam> listStuScoreParam = stuScoreMapper.listAllCourseScore(student.getStuNo(), student.getClassId());
        return listStuScoreParam;
    }

    @Override
    public List<StuScore> listResitCourse() {
        List<StuScore> listStuScore = stuScoreMapper.listResitCourseScore(RequestHolder.getCurrentStudent().getStuNo());
        if (listStuScore.size() <= 0) {
            throw new ParamException("没有补考课程信息");
        }
        return listStuScore;
    }

    @Override
    public List<StuScore> listRetakeCourse() {
        List<StuScore> listStuScore = stuScoreMapper.listRetakeCourseScore(RequestHolder.getCurrentStudent().getStuNo());
        if (listStuScore.size() <= 0) {
            throw new ParamException("没有重修课程信息");
        }
        return listStuScore;
    }

}
